package com.fudan.backend.pojo;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.util.List;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Order {
    private String orderId;
    private String userId;
    private String storeId;
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date payTime;
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date deliveryTime;
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date takeTime;
    private String billId;
    private String addressId;
    private String activityId;
    private Double allowance;
    private Double payment;
    private Integer status;
    private Double originSum;
    private Integer is_deleted;
    private String moreInfo;
    private List<OrderItem> orderItemList;

    public Order(String orderId, String userId, String storeId, Date createTime, Date payTime, Date deliveryTime, Date takeTime, String billId, String addressId, String activityId, Double allowance, Double payment, Integer status, Integer is_deleted, String moreInfo, List<OrderItem> orderItemList) {
        this.orderId = orderId;
        this.userId = userId;
        this.storeId = storeId;
        this.createTime = createTime;
        this.payTime = payTime;
        this.deliveryTime = deliveryTime;
        this.takeTime = takeTime;
        this.billId = billId;
        this.addressId = addressId;
        this.activityId = activityId;
        this.allowance = allowance;
        this.payment = payment;
        this.status = status;
        this.is_deleted = is_deleted;
        this.moreInfo = moreInfo;
        this.orderItemList = orderItemList;
        this.originSum = 0.0;
    }

    public Order(Order order) {
        this.orderId = order.orderId;
        this.userId = order.userId;
        this.storeId = order.storeId;
        this.createTime = order.createTime;
        this.payTime = order.payTime;
        this.deliveryTime = order.deliveryTime;
        this.takeTime = order.takeTime;
        this.billId = order.billId;
        this.addressId = order.addressId;
        this.activityId = order.activityId;
        this.allowance = order.allowance;
        this.payment = order.payment;
        this.status = order.status;
        this.is_deleted = order.is_deleted;
        this.moreInfo = order.moreInfo;
        this.originSum = order.originSum;
        this.orderItemList = order.orderItemList;
    }
}
